<?php

class gDboAdapterAbstract extends gCoreObject
{	
	protected $_connection = null;
	
	protected $_lastError  = null;
	/**
	 * 
	 * Enter description here ...
	 * @var gDboQuery
	 */
	protected $_query = null;
	/**
	 * 
	 * Enter description here ...
	 * @var gDboTable
	 */
	protected $_table = null;
	
	public function init()
	{
		$this->_query = new gDboQuery($this);
		$this->_table = new gDboTable($this);
	}
	
	public function connect()
	{
		
	}
	
	public function disconnect()
	{
		
	}
	/**
	 * 
	 * Enter description here ...
	 * @return gDboQuery
	 */
	public function select()
	{
		return $this->_query->select();
	}
	/**
	 * 
	 * Enter description here ...
	 * @return gDboQuery
	 */
	public function update()
	{
		return $this->_query->update();
	}
	/**
	 * 
	 * Enter description here ...
	 * @return gDboQuery
	 */
	public function delete()
	{
		return $this->_query->delete();
	}
	
	public function execute($sql,$result = null)
	{
		
	}
	
	public function prepare($sql)
	{
		if( is_object($sql) )
		{
			$sql = $sql->toString();
		}
		$values = func_get_args()>1 ? array_slice(func_get_args(),1) : array();
		
		foreach ($values as $key => &$value)
		{
			$sql = preg_replace('/\?/',is_string($value)?gDboQuery::quoteValue.$value.gDboQuery::quoteValue:$value,$sql,1);
		}
		return $sql;
	}
	
	
}